package com.yuan.model_community.repository;

import com.yuan.model_community.domain.CommunityHouse;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface CommunityHouseDao extends JpaRepository<CommunityHouse, Integer>, JpaSpecificationExecutor<CommunityHouse> {

    @Query(value = "select cb.buildingName from CommunityBuilding cb where cb.buildingId = :buildingId")
    String findBuildingNameById(Integer buildingId);

    @Query(value = "select cu.unitName from CommunityUnit cu where cu.unitId = :unitId")
    String findUnitNameById(Integer unitId);

    @Query(value = "select user.nickName from User user where user.id = :liverId")
    String findUserNameById(Long liverId);

    @Query(value = "select house from CommunityHouse house where house.liverId = :userId")
    CommunityHouse findHouseByUserId(Long userId);

}
